package com.sss.springcloud.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.sss.springcloud.common.Result;
import com.sss.springcloud.entities.Orders;
import com.sss.springcloud.service.AccountService;
import com.sss.springcloud.service.IOrdersService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sss
 * @since 2020-03-13
 */
@RestController
@RequestMapping("/order")
public class OrdersController {
    @Resource
    private IOrdersService orderService;


    @GetMapping("/create")
    @SentinelResource(value = "fallbackaa",fallback = "fallbackHandler")
    public Result create(Orders order){
        boolean b = orderService.create(order);
        //List<Orders> list = orderService.list();
        //int age=10/0;
        return Result.succes(b);
    }


    public Result fallbackHandler(Orders order, Throwable ex){
        return Result.fail(444,"fallback兜底方法");
    }
}

